package com.ccsoft.atools.controller;


import com.ccsoft.atools.model.SysObject;
import com.ccsoft.atools.service.SysObjectService;
import com.ccsoft.atools.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/sysObject")
public class SysObjectController {

    @Autowired
    private SysObjectService service;

    @DeleteMapping("/deleteByPrimaryKey/{iid}")
    public JsonResult deleteByPrimaryKey(@PathVariable java.lang.Integer iid) {
        return JsonResult.ok(service.deleteByPrimaryKey(iid));
    }

    @GetMapping("/selectByPrimaryKey/{iid}")
    public JsonResult selectByPrimaryKey(@PathVariable java.lang.Integer iid) {
        return JsonResult.ok(service.selectByPrimaryKey(iid));
    }

    @GetMapping("/selectAll")
    public JsonResult selectAll() {
        return JsonResult.ok(service.selectAll());
    }

    @PostMapping("/insert")
    public JsonResult insert(@RequestBody SysObject record) {
        return JsonResult.ok(service.insertSelective(record));
    }

    @PutMapping("/update")
    public JsonResult update(@RequestBody SysObject record) {
        return JsonResult.ok(service.updateByPrimaryKey(record));
    }

    @GetMapping("/selectByModule/{moduleSid}")
    public JsonResult selectByModule(@PathVariable String moduleSid) {
        return JsonResult.ok(service.selectByModule(moduleSid));
    }

}